package com.joshondesign.sdljava.gfx;

import com.joshondesign.sdljava.SDL_MouseButtonEvent;
import com.joshondesign.sdljava.SDL_Rect;

/**
 * Created by IntelliJ IDEA.
 * User: josh
 * Date: 9/10/11
 * Time: 5:04 PM
 * To change this template use File | Settings | File Templates.
 */
public class Bounds {
    private SDL_Rect sdl_rect;
    int x;
    int y;
    int width;
    int height;

    public Bounds(SDL_Rect sdl_rect) {
        this.sdl_rect = sdl_rect;
        this.x = sdl_rect.getX();
        this.y = sdl_rect.getY();
        this.width = sdl_rect.getW();
        this.height = sdl_rect.getH();
    }

    public Bounds(int x, int y, int width, int height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public int getWidth() {
        return width;
    }

    public int getHeight() {
        return height;
    }

    @Override
    public String toString() {
        return "Bounds{" +
                "x=" + x +
                ", y=" + y +
                ", width=" + width +
                ", height=" + height +
                '}';
    }

    public boolean inside(SDL_MouseButtonEvent button) {
        if(button.getX() >= x && button.getX() <= x + width) {
            if(button.getY() >=y && button.getY()<= y+height) {
                return true;
            }
        }
        return false;
    }
}
